package com.rayc.service.impl;

import com.codingapi.txlcn.tc.annotation.LcnTransaction;
import com.rayc.mapper.OrderMapper;
import com.rayc.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;

@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper orderMapper;
    @Autowired
    RestTemplate restTemplate;
    @Override
    @Transactional
    @LcnTransaction
    public void createOrder() {
        //1、减库存
        restTemplate.getForObject("http://localhost:8085/item", String.class);
        System.out.println("减库存");
//        int i = 1/0;
        //2、创建订单
        orderMapper.save();
    }
}
